<?php require_once '../yubiphpbase/appinclude.php';
require_once '../yubiphpbase/yubi_lib.php';
include 'head.htm';
$act = getHttpVal('act', '');
$msg = getHttpVal('msg', '');
$keyId = getHttpVal('keyid', '');

if (($usrid = getUsrIdFromSession()) <= 0) {
	echo TIMEDOUT;
	exit;
}

if (strlen($act) > 0) {
	if (strcmp($act,'chg_key') == 0) {
		$msg = '';
	    $stmt = 'UPDATE yubikeys SET active='.getHttpVal('active',1).
	    		',SET notes='.mysql_quote(getHttpVal('notes',1)).
				' WHERE id='.$_SESSION['client'];
		if (query($stmt)) {
			$_SESSION['email'] = $email;
		} else {
			$msg = 'Failed to change admin email, check input and try again?';
		}
	} // End act
}

?>

<title>Yubikey Information</title>

<body>

<div align=left id="E" style=background:#eeeeee;>
<table border=1>

<tr><td align=center colspan=2>
<?php
if (strlen($msg) > 0) {
	echo '<font color=red>'.$msg.'</font>';
}

$a = getKeyInfoById($keyId, $_SESSION['client']);
?>
</td></tr>

<tr><td valign=top align=center colspan=2> 
<h2>Yubikey Information</h2>
<br><p>
<form name=chg_key id=chg_key method=POST action=edit_key.php>
<input name=act type=hidden value=chg_key>

<img src=images/undercon.gif><p>
As an admin, you can request for the AES secret keys of your Yubikeys.
<br><br>

<tr>
<td align=left width=50%>
<b>Yubikey state:</b>
</td><td align=left>

<select name=active>
<option value="0" <?php if ($a['active']==0) echo 'selected'; ?>>Inactive
<option value="1" <?php if ($a['active']==1) echo 'selected'; ?>>Active
</select>

</td>
</tr>

<tr>
<td align=left width=50%>
<b>Note:</b>
</td><td align=left>
<input name=notes value="<?php echo $a['notes'];?>">
</td>
</tr>

<tr><td colspan=2 align=center>
<br>
<input type=submit value="Update" class=buttonLinkSmall>
</form>

</td></tr>

<tr><td colspan=2 align=center>
<br>
<img src=images/close.gif>
<A href="javascript:window.close();">Close this window</A>
</td></tr>

</table>
